package net.laoyeye.yyblog.service.impl;

import java.util.Date;
import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import net.laoyeye.yyblog.common.DataGridResult;
import net.laoyeye.yyblog.enums.JobStatusEnum;
import net.laoyeye.yyblog.mapper.TPlanMapper;
import net.laoyeye.yyblog.mapper.TaskMapper;
import net.laoyeye.yyblog.model.TPlan;
import net.laoyeye.yyblog.model.TaskDO;
import net.laoyeye.yyblog.model.UserDO;
import net.laoyeye.yyblog.model.query.BaseQuery;
import net.laoyeye.yyblog.model.query.TaskQuery;
import net.laoyeye.yyblog.model.vo.TaskVO;
import net.laoyeye.yyblog.quartz.utils.QuartzManager;
import net.laoyeye.yyblog.service.TPlanService;
import net.laoyeye.yyblog.service.TaskService;

@Service
public class TPlanServiceImpl implements TPlanService {

    @Autowired
    private TPlanMapper tPlanMapper;

	@Override
	public int deleteByPrimaryKey(Integer id) {
		// TODO Auto-generated method stub
		return tPlanMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(TPlan tPlan) {
		// TODO Auto-generated method stub
		return tPlanMapper.insert(tPlan);
	}

	@Override
	public int insertSelective(TPlan tPlan) {
		// TODO Auto-generated method stub
		return tPlanMapper.insertSelective(tPlan);
	}

	@Override
	public int updateByPrimaryKeySelective(TPlan tPlan) {
		// TODO Auto-generated method stub
		return tPlanMapper.updateByPrimaryKeySelective(tPlan);
	}

	@Override
	public int updateByPrimaryKey(TPlan tPlan) {
		// TODO Auto-generated method stub
		return tPlanMapper.updateByPrimaryKey(tPlan);
	}

	@Override
	public TPlan selectById(Integer id) {
		// TODO Auto-generated method stub
		return tPlanMapper.selectById(id);
	}

	@Override
	public List<TPlan> findPageWithResult(TPlan tPlanDTO) {
		// TODO Auto-generated method stub
		return tPlanMapper.findPageWithResult(tPlanDTO);
	}

	@Override
	public Integer findPageWithCount(TPlan tPlanDTO) {
		// TODO Auto-generated method stub
		return tPlanMapper.findPageWithCount(tPlanDTO);
	}

	@Override
	public DataGridResult listPage(BaseQuery query) {
		 PageHelper.startPage(query.getPage(), query.getLimit()); 
	        List<TPlan> list = tPlanMapper.listPage(null);
	        //取记录总条数
	        PageInfo<TPlan> pageInfo = new PageInfo<TPlan>(list);
	        long total = pageInfo.getTotal();
	        //创建一个返回值对象
	        DataGridResult result = new DataGridResult(); 
	        result.setData(list);
	        result.setCount(total);
	        return result;
	}

}
